home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / PET / S-Super PET / (s)tk.d64 / trs80pUTcHAR.ASM < prev    next >
Assembly Source File  |  2009-01-18  |  4KB  |  151 lines

  1. ;TRS80 - DMP 105 printer driver written by Avygdor Moise.
  2.  
  3. ;       This program will enable all SuperPET programs to use TRS 80
  4. ;       printer via the RS-232C interface using the  'Put serial'
  5. ;       command (from editors, languages and PetCom's List mode) .
  6.  
  7. opt nolist
  8.  
  9. xref    TBreak_ ,ACIAstatus, ACIAdata
  10. xref    STREq_
  11.  
  12. SysOpen_hook    equ     14
  13. SysOpen_offset  equ     2*(SysOpen_hook+1)
  14.  
  15. SysWrite_hook   equ     3
  16. SysWrite_offset equ     2*(SysWrite_hook+1)
  17.  
  18. SysNL_hook      equ     8
  19. SysNL_offset    equ     2*(SysNL_hook+1)
  20.  
  21. service_        equ     $32
  22. memtop_         equ     $22
  23.  
  24.         ldb     #SysOpen_offset
  25.         stb     $0580+SysOpen_hook      ;connect to SysOpen
  26.         ldd     #SysOpen
  27.         std     $05c0+SysOpen_offset    ;address of replacement to Sys$Open
  28.  
  29.         ldb     #SysWrite_offset
  30.         stb     $0580+SysWrite_hook     ;connect to SysWrite
  31.         ldd     #SysWrite
  32.         std     $05c0+SysWrite_offset   ;address of replacement to Sys$write
  33.  
  34.         ldb     #SysNL_offset           ;connect to SysNL
  35.         stb     $0580+SysNL_hook
  36.         ldd     #SysNL
  37.         std     $05c0+SysNL_offset
  38.  
  39.         ldd     #start-1
  40.         std     memtop_
  41.         clr     service_
  42.         rts
  43.  
  44. start   equ     *
  45.  
  46. line_count      fcb     0               ;number of lines to end of page
  47.  
  48. lines_per_page          equ     66
  49. serial                  equ     $06     ;hook identification number for device
  50. DSR_DCD_TDE_mask        equ     %01110000
  51. ready                   equ     %00010000
  52.  
  53. SysWrite        equ     *
  54.  
  55.         ldx     5,s                     ;fcb
  56.         ldx     4,x                     ;point to file info
  57.         ldb     2,x                     ;get device type
  58.         cmpb    #serial
  59.         if      eq
  60.                 pshs    y
  61.                 ldx     11,s            ;buffer address
  62.                 ldy     13,s            ;buffer length
  63.                 if      ne
  64.                         loop                            ;output the buffer
  65.                                 ldb     ,x+
  66.                                 bsr     SPutChar
  67.                                 leay    -1,y            ;decrement count
  68.                         until   eq
  69.                 endif
  70.                 puls    y
  71.                 leas    7,s                                     ;drop SysWrite_
  72.         endif
  73.         rts
  74.  
  75. SysNL   equ     *
  76.  
  77.         ldx     6,s
  78.         ldx     4,x
  79.         ldb     2,x
  80.         cmpb    #serial
  81.         if      eq
  82.                 ldb     #$0d
  83.                 bsr     SPutChar
  84.                 leas    8,s
  85.         endif
  86.         rts
  87.  
  88. SPutChar        equ     *
  89.  
  90.         pshs    d,cc
  91.  
  92.         guess
  93.                 cmpb    #$0a            ;line feed ?
  94.         quif    eq
  95.                 cmpb    #$0d            ;let the printer empty its buffer
  96.         quif    eq
  97.                 cmpb    #$0c
  98.                 if      eq
  99.                         ldb     #$0a    ;linefeed
  100.                         loop
  101.                                 bsr     SPutChar
  102.                                 lda     #lines_per_page
  103.                                 suba    line_count
  104.                         until   eq
  105.                 else
  106.                         bsr     SPutChar_
  107.                 endif
  108.         admit
  109.                 dec     line_count
  110.                 if      eq
  111.                         lda     #lines_per_page
  112.                         sta     line_count
  113.                 endif
  114.                 bsr     SPutChar_
  115.         endguess
  116.  
  117.         puls    cc,d,pc
  118.  
  119. SPutChar_       equ     *
  120.  
  121.         pshs    a,cc
  122.         loop
  123.                 lda     #DSR_DCD_TDE_mask       ;mask all but DSR,DCD,TDE
  124.                 anda    ACIAstatus
  125.                 eora    #ready                  ;is printer ready  ?
  126.         quif    eq
  127.                 cwai    #$ff                    ;wait for a transition
  128.         endloop
  129.         stb     ACIAdata
  130.         cwai    #$ff                            ;wait for acknnowledge
  131.  
  132.         puls    cc,a,pc
  133.  
  134. SysOpen equ     *
  135.  
  136.         ldd     $3E,s           ;get name string address
  137.         pshs    d
  138.         ldd     #interface
  139.         jsr     streq_
  140.         leas    2,s
  141.         if      ne
  142.                 lda     #66
  143.                 sta     line_count
  144.         endif
  145.         rts
  146.  
  147. interface       fcc     "serial"
  148.                 fcb     0
  149.  
  150. end
  151.